package interceptor

import (
	"go-quick/interface/iweb"
)

type LoggerInterceptor struct{}

func NewLogger() *LoggerInterceptor {
	return &LoggerInterceptor{}
}

func (l *LoggerInterceptor) Name() string {
	return "logger-interceptor"
}

func (l *LoggerInterceptor) Before(ctx iweb.IHttpContext) bool {
	ctx.Log().InfoF("Before => HTTP请求日志 [%s:%s]", ctx.Path(), ctx.Method())
	return true
}

func (l *LoggerInterceptor) After(ctx iweb.IHttpContext) bool {
	ctx.Log().InfoF("After => HTTP请求日志 [%s:%s]", ctx.Path(), ctx.Method())
	return true
}
